package coding.datastructures;

import java.util.HashMap;
import java.util.Map;

public class CompressionString {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String str1 = "aabcccddaaa";
		System.out.println(compressNormal(str1));
	}

	public static String compressNormal(String str) {
		String mystr = "";
		char last = str.charAt(0);
		int count = 1;
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == last) {
				count++;
			} else {
				mystr += last + "" + count;
				last = str.charAt(i);
				count = 1;
			}
		}
		return mystr + last + count;
	}
	
}
